/**
 * Validate v1.0.0 通用验证
 * @description 项目中用到的表单验证规则
 */
import test from '@/sheep/helper/test.js';

// 手机号
export const mobile = {
  rules: [
    {
      required: true,
      errorMessage: '请输入手机号',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!test.mobile(value)) {
          callback('手机号码格式不正确');
        }
        return true;
      },
    },
  ],
};

// 账户
export const account = {
  rules: [
    {
      required: true,
      errorMessage: '请输入账号',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (value.length < 5) {
          callback('账号长度不能小于5位');
        }
        return true;
      },
    },
  ],
};

// 密码
export const password = {
  rules: [
    {
      required: true,
      errorMessage: '请输入密码',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+\S{5,12}$/.test(value)) {
          callback('需包含字母和数字,长度在6-12之间');
        }
        return true;
      },
    },
  ],
};
// 再次确认密码
export const confirmPwd = {
  rules: [
    {
      required: true,
			errorMessage: '请再次输入新密码',
    },
    {
      validateFunction: function(rule, value, data, callback) {
        if (value != data.password) {
          callback('两次输入的密码必须相同')
        }
        return true
      },
    },
    
  ],
};
// 昵称
export const username = {
  rules: [
    {
      required: true,
      errorMessage: '请输入用户名',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (value.length < 5) {
          callback('用户名长度不能小于5位');
        }
        return true;
      },
    },
  ],
};

// 短信验证码
export const code = {
  rules: [
    {
      required: true,
      errorMessage: '请输入验证码',
    },
  ],
};
// 性别
export const sex = {
  rules: [
    {
      required: true,
      errorMessage: '请选择性别',
    },
  ],
};
// 真实姓名
export const realName = {
  rules: [
    {
      required: true,
      errorMessage: '请输入姓名',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!test.chinese(value)) {
          callback('请输入汉字');
        }
        return true;
      },
    },
  ],
};
//身份证号
export const identityCard = {
  rules: [
    {
      required: true,
      errorMessage: '请输入身份证号',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!test.idCard(value)) {
          callback('身份证号格式不正确');
        }
        return true;
      },
    },
  ],
};
export const taxName = {
  rules: [
    {
      required: true,
      errorMessage: '请输入发票抬头名称',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!test.chinese(value)) {
          callback('请输入汉字');
        }
        return true;
      },
    },
  ],
};

// 税号
export const taxNo = {
  rules: [
    {
      required: true,
      errorMessage: '请输入税号',
    },
  ],
};

// 开户行
export const bankName = {
  rules: [
    {
      required: true,
      errorMessage: '请输入开户行',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!test.chinese(value)) {
          callback('请输入汉字');
        }
        return true;
      },
    },
  ],
};
//开户支行
export const bank_branch = {
  rules: [
    {
      required: true,
      errorMessage: '请输入开户支行',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!test.chinese(value)) {
          callback('请输入汉字');
        }
        return true;
      },
    },
  ],
};
// 银行卡号
export const bankCode = {
  rules: [
    {
      required: true,
      errorMessage: '请输入银行卡号',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!test.number(value)) {
          callback('请输入正确账号');
        }
        return true;
      },
    },
  ],
};

// 支付宝账号
export const alipayAccount = {
  rules: [
    {
      required: true,
      errorMessage: '请输入支付宝账号',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        let isEmail = test.email(value);
        let isMobile = test.mobile(value);

        if (!isEmail && !isMobile) {
          callback('请输入正确账号');
        }
        return true;
      },
    },
  ],
};

export const consignee = {
  rules: [
    {
      required: true,
      errorMessage: '请输入收货人姓名',
    },
  ],
};

export const region = {
  rules: [
    {
      required: true,
      errorMessage: '请选择您的位置',
    },
  ],
};
export const address = {
  rules: [
    {
      required: true,
      errorMessage: '请输入详细地址',
    },
  ],
};
//公司名称
export const company = {
  rules: [
    {
      required: true,
      errorMessage: '请输入公司名称',
    },
  ],
};
//拜访事由
export const reason = {
  rules: [
    {
      required: true,
      errorMessage: '请输入拜访事由',
    },
  ],
};

//项目
export const project = {
  rules: [
    {
      required: true,
      errorMessage: '请输入项目名称',
    },
  ],
};
//岗位
export const station = {
  rules: [
    {
      required: true,
      errorMessage: '请输入岗位名称',
    },
  ],
};
// 部门id
export const department_id = {
  rules: [
    {
      required: true,
      errorMessage: '请选择部门',
    },
  ],
};
//待遇
export const treatment = {
  rules: [
    {
      required: true,
      errorMessage: '请输入福利待遇',
    },
  ],
};

// 结算方式
export const meansOfPayments = {
  rules: [
    {
      required: true,
      errorMessage: '请选择结算方式',
    },
  ],
};
// 职位名称
export const jobTitle = {
  rules: [
    {
      required: true,
      errorMessage: '请输入职位名称',
    },
  ],
};
// 工作经验
export const jobExperience = {
  rules: [
    {
      required: true,
      errorMessage: '请输入工作经验',
    }
  ],
};
// 城市
export const city = {
  rules: [
    {
      required: true,
      errorMessage: '请选择城市',
    },
  ],
};
// 联系方式
export const contactWay = {
  rules: [
    {
      required: true,
      errorMessage: '请输入联系方式',
    },
    {
      validateFunction: function (rule, value, data, callback) {
        if (!test.mobile(value)) {
          callback('手机号码格式不正确');
        }
        return true;
      },
    },
  ],
};
// 男人数
export const menNumber = {
  rules: [
    {
      required: true,
      errorMessage: '请输入男人数',
    },
    {
      format: 'number',
      errorMessage: '只能输入数字'
     },
  ],
};
// 女人数
export const womenNumber = {
  rules: [
    {
      required: true,
      errorMessage: '请输入女人数',
    },
    {
      format: 'number',
      errorMessage: '只能输入数字'
     },
  ],
};
// 截止日期
export const date = {
  rules: [
    {
      required: true,
      errorMessage: '请选择日期',
    },
  ],
};
// 开始时间
export const start_time = {
  rules: [
    {
      required: true,
      errorMessage: '请选择开始日期',
    },
  ],
};
// 结束时间
export const end_time = {
  rules: [
    {
      required: true,
      errorMessage: '请选择开始日期',
    },
  ],
};
// 内容
export const content = {
  rules: [
    {
      required: true,
      errorMessage: '请输入内容',
    },
  ],
};
// 工资范围
export const wage = {
  rules: [
    {
      required: true,
      errorMessage: '请输入工资范围,只能是数字',
    }
  ],
};
//分类
export const classify = {
  rules: [
    {
      required: true,
      errorMessage: '请选择分类',
    }
  ],
};
// 名称
export const title = {
  rules: [
    {
      required: true,
      errorMessage: '请输入名称',
    }
  ],
};
// 编号
export const serialNumber = {
  rules: [
    {
      required: true,
      errorMessage: '请输入编号',
    }
  ],
};
// 品牌
export const brand = {
  rules: [
    {
      required: true,
      errorMessage: '请输入品牌',
    }
  ],
};
// 型号
export const model = {
  rules: [
    {
      required: true,
      errorMessage: '请输入型号',
    }
  ],
};
// 规格数量
export const number = {
  rules: [
    {
      required: true,
      errorMessage: '请输入数量',
    },
    {
      format: 'number',
      errorMessage: '只能输入数字'
     },
  ],
};
//账户信息
export const information = {
  rules: [
    {
      required: true,
      errorMessage: '请选择账户信息',
    },
  ],
};
//借款额度
export const quantity = {
  rules: [
    {
      required: true,
      errorMessage: '请输入借款金额',
    },
  ],
};
//类型
export const type = {
  rules: [
    {
      required: true,
      errorMessage: '请输入',
    },
  ],
};
export const payment_type = {
  rules: [
    {
      required: true,
      errorMessage: '请选择类型',
    },
  ],
};

export default {
  mobile,
  alipayAccount,
  bankCode,
  bankName,
  realName,
  identityCard,
  password,
  confirmPwd,
  code,
  account,
  consignee,
  address,
  region,
  taxNo,
  taxName,
  reason,
  company,
  wage,
  content,
  date,
  womenNumber,
  menNumber,
  contactWay,
  city,
  jobExperience,
  jobTitle,
  meansOfPayments,
  treatment,
  station,
  project,
  classify,
  bank_branch,
  type:'',
    title,
    serialNumber,
    brand,
    model,
    number,
    quantity,
    information,
    start_time,
    end_time,
    payment_type
};
